#/bin/bash
Cur_day=`date -d '1 day ago' +%Y%m%d`
TIME_WAIT_MAX=36000
TIME_SLEEP=300
#运行时传城市参数进来 $1
bj_today=$1"_$Cur_day"
Local_inputdata_path=/usr/local/apps/hadoop/data
Local_code_path=/usr/local/apps/hadoop/rent
Local_hadoop_path=/usr/local/apps/hadoop-2.7.2/share/hadoop/tools/lib
#mapred3
hadoop jar $Local_hadoop_path/hadoop-streaming-2.7.2.jar \
-input /house_rent/$bj_today/house_rent_gov.gz \
-output  /house_rent/$bj_today/mapred3 \
-mapper '/usr/bin/php mapper_3.php' \
-reducer '/usr/bin/php reducer3_1.php' \
-file '/usr/local/apps/hadoop/rent/mapper_3.php' \
-file '/usr/local/apps/hadoop/rent/reducer3_1.php'
#mapred4
hadoop jar $Local_hadoop_path/hadoop-streaming-2.7.2.jar \
-D mapreduce.job.reduces=1 \
-input /house_rent/$bj_today/mapred3/part-00000 \
-output /house_rent/$bj_today/mapred4 \
-mapper '/usr/bin/php mapper_4.php' \
-reducer '/usr/bin/php reducer_4_3.php' \
-file '/usr/local/apps/hadoop/rent/mapper_4.php' \
-file '/usr/local/apps/hadoop/rent/reducer_4_3.php'
#step5 sql file(house_rent_info)
hadoop jar $Local_hadoop_path/hadoop-streaming-2.7.2.jar \
-D mapreduce.job.reduces=0 \
-input /house_rent/$bj_today/mapred4/part-00000 \
-output /house_rent/$bj_today/mapred5 \
-mapper '/usr/bin/php mapper5.php' \
-file '/usr/local/apps/hadoop/rent/mapper5.php'
hadoop fs -copyToLocal /house_rent/$bj_today/mapred5/* $Local_inputdata_path/rent/$bj_today/
#step6 sql file(house_rent)
hadoop jar $Local_hadoop_path/hadoop-streaming-2.7.2.jar \
-D mapreduce.job.reduces=0 \
-input /house_rent/$bj_today/mapred4/part-00000 \
-output /house_rent/$bj_today/mapred6 \
-mapper '/usr/bin/php mapper6.php' \
-file '/usr/local/apps/hadoop/rent/mapper6.php'
hadoop fs -copyToLocal /house_rent/$bj_today/mapred6/* $Local_inputdata_path/rent/$bj_today/house_rent
#step7 sql file(house_rent_gov)
hadoop jar $Local_hadoop_path/hadoop-streaming-2.7.2.jar \
-D mapreduce.job.reduces=0 \
-input /house_rent/$bj_today/mapred4/part-00000 \
-output /house_rent/$bj_today/mapred7 \
-mapper '/usr/bin/php mapper7_2_20.php' \
-file '/usr/local/apps/hadoop/rent/mapper7_2_20.php'
hadoop fs -copyToLocal /house_rent/$bj_today/mapred7/* $Local_inputdata_path/rent/$bj_today/house_rent_gov

